import vue from '@vitejs/plugin-vue'
import Unocss from 'unocss/vite'
import createRestart from './restart'
import createHtml from './html'
import createSvgIcon from './svg-icon'
import createI18n from './i18n'
import createMock from './mock'
import createCompression from './compression'
import createSpritesmith from './spritesmith'
import createBanner from './banner'
import createPwa from './pwa'

export default function createVitePlugins(viteEnv, isBuild = false) {
  const vitePlugins = [vue()]
  !isBuild && vitePlugins.push(createRestart())
  vitePlugins.push(createHtml(viteEnv, isBuild))
  vitePlugins.push(createSvgIcon(isBuild))
  vitePlugins.push(createI18n())
  // vitePlugins.push(createMock())
  isBuild && vitePlugins.push(...createCompression(viteEnv))
  vitePlugins.push(...createSpritesmith())
  vitePlugins.push(createBanner())
  isBuild && viteEnv.VITE_BUILD_PWA == 'true' && vitePlugins.push(createPwa())
  return vitePlugins
}
